<?php declare(strict_types=1);


namespace App\Rpc\Service;
use App\Rpc\Lib\PayAccountInterface;
use Swoft\Redis\Pool;
use Swoft\Bean\Annotation\Mapping\Inject;
use Swoft\Rpc\Server\Annotation\Mapping\Service;

/**
 * Class MessageService
 *
 * @since 2.0
 *
 * @Service()
 */
class PayAccountService implements PayAccountInterface
{

    /**
     * @Inject("redis.pool")
     * @var Pool
     */
    private $connectionRedis;

    /**
     * @Inject("rabbit.pool")
     * @var \Six\Rabbit\Pool
     */
    private $rabbit;


    /**
     * 尝试提交（第一阶段try）
     * @param $context
     * @return array
     */
    public function creditAccountTcc($context): array
    {
        var_dump('account第一阶段try');
        return ['status' => 1 ,'result' => 'Account第一阶段try'];
    }

    /**
     * 业务提交执行（第二阶段Confirm）
     * @param $context
     * @return array
     */
    public function confirmCreditAccountTcc($context): array
    {
        var_dump('Account第二阶段Confirm');
        return ['status' => 1 ,'result' => 'Account第二阶段Confirm'];
    }

    /**
     * 回滚（第二阶段cancel）
     * @param $context
     * @return array
     */
    public function cancelCreditAccountTcc($context): array
    {
        var_dump('Account第二阶段cancel');
        return ['status' => 1 ,'result' => 'Account第二阶段cancel'];
    }

}